package com.istock.union.user.translate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.istock.base.export.data.TranslateCallback;
import com.istock.base.spring.SpringContextHolder;
import com.istock.union.user.dao.TenantInfoMapper;
import com.istock.union.user.model.TenantInfo;
import com.istock.union.user.model.TenantInfoExample;

/**
 * 翻译租户的回调
 * @author senvon
 *
 */
public class TenantTranslateCallback implements TranslateCallback {

	@Override
	public Map<Object, Object> translate(List codeList) {
		TenantInfoMapper tenantInfoMapper = SpringContextHolder.getInstance().getBean(TenantInfoMapper.class);
		TenantInfoExample example = new TenantInfoExample();
		TenantInfoExample.Criteria criteria = example.createCriteria();
		criteria.andTenantCodeIn(codeList);
		example.setDistinct(true);
		List<TenantInfo> tenantList = tenantInfoMapper.selectByExample(example);
		if(tenantList != null) {
			Map result = new HashMap();
			for(TenantInfo tenantInfo : tenantList) {
				result.put(tenantInfo.getTenantCode(), tenantInfo);
			}
			return result;
		}
		return null;
	}

}
